package com.anxin.registerManagement.controller;

import com.anxin.registerManagement.bean.dto.FinanceSearchJo;
import com.anxin.registerManagement.bean.persist.Finance;
import com.anxin.registerManagement.service.FinanceService;
import com.anxin.registerManagement.util.ResultUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author anxin
 * @date 2022/4/10 11:12
 */
@RestController
@RequestMapping("/finances")
public class FinanceController {

    @Autowired
    FinanceService financeService;

    @PostMapping("/search")
    public ResultUtil search(@RequestBody FinanceSearchJo financeSearchJo) {
        return ResultUtil.success(financeService.search(financeSearchJo));
    }

    @PostMapping("/add")
    public ResultUtil add(@RequestBody Finance finance) {
        financeService.add(finance);
        return ResultUtil.success();
    }

    @PostMapping("/update")
    public ResultUtil update(@RequestBody Finance finance) {
        financeService.update(finance);
        return ResultUtil.success();
    }

    @PostMapping("/delete")
    public ResultUtil delete(@RequestParam("id") List<Integer> id) {
        financeService.delete(id);
        return ResultUtil.success();
    }

}
